
/**
 * 创建时间: 2020/7/2 15:36
 * 作者:lixu
 * 功能描述: 系统配置
 * 修改时间:
 * 修改描述:
 */
public class SysConfig {
    
    public var ip:String = "" ;
    public var port:Int = 0;

    /**
     * 应用版本号 1.x.x
     */
    public var appVersion:String = "";
    /**
     * 系统版本
     */
    public var system:String = "";
    /**
     * 设备ID
     */
    public var deviceId:String = "";
    
    //类型
    public var clientType:String = "";

    //用户ID
    public var userId:String = "";
    /**
     * 控制台是否打印日志
     */
    public var isConsoleLogOpen:Bool = true;

    public func checkData() ->Bool{
        return !ip.isEmpty && port > 0 ;
    }

    
    public func toString() ->String {
        return "SysConfig{ip='\(ip)', port='\(port), version='\(appVersion)', system='\(system), deviceId='\(deviceId)', isConsoleLogOpen=‘\(isConsoleLogOpen)’}";
        
        /*
         "SysConfig{" +
         "ip='" + ip + "\'" +
         ", port=" + port +
         ", version='" + appVersion + "\'" +
         ", system='" + system + "\'" +
         ", deviceId='" + deviceId + "\'" +
         ", isConsoleLogOpen=" + isConsoleLogOpen +
         "}";
         
         */
    }

    public static func fromJsonMap( map:[String:Any])->SysConfig {

        let sysConfig = SysConfig();
        sysConfig.ip =  map["ip"] as! String;
        sysConfig.port = map["port"] as! Int;
        sysConfig.appVersion =  map["appVersion"] as! String;
        sysConfig.system =  map["system"] as! String;
        sysConfig.userId =  map["userId"] as! String;
        sysConfig.clientType =  map["clientType"] as! String;
        sysConfig.deviceId = map["deviceId"] as! String;
        sysConfig.isConsoleLogOpen = map["isConsoleLogOpen"] as! Bool;
        return sysConfig;
    }

    
    
    public static func fromJsonimConfigMap( map:[String:Any])->SysConfig {

        let sysConfig = SysConfig();
        sysConfig.ip =  map["ip"] as! String;
        sysConfig.port = map["port"] as! Int;
      
        return sysConfig;
    }
    
}
